Release Note
New Features
- Improve type inference in
Contractmodule when using typescript.- The
Contractnow infers method signatures based on the provided ABI. - To enable accurate inference, the ABI should be defined using the
as constassertion or passed directly into tronWeb.contract(). - The contract instance created using
tronWeb.contract().new(), ortronWeb.contract().at()will not have type inference by default. To enable type inference, you need to cast it usingas ContractInstance<typeof abi>. - After enabling type inference, if a contract method argument is an array, you must either pass the array directly to the method or use as const to narrow the argument type.
- The
send()method accepts aSendOptionsobject as its sole parameter. To ensure the correct return type is inferred, pass the object directly to the method or useas constto narrow the argument type.
- The
Change
- Change the return behavior of the
contract.new()method.- Previously, this method mutated the current instance and used the ABI stored on the Tron blockchain, which proved to be unreliable. It now returns a new instance that uses the ABI provided in the options parameter.
- Change props type of
CallOptionsandSendOptions.CallOptionsdeletedcallTokenValue/callTokenId/userFeePercentageand shouldPollResponse, addedtokenValueandtokenId.SendOptionsdeletedrawParameteranduserFeePercentage, addedtokenValueandtokenId.
- Export
GetEventResultOptionsandEventResponse. - Allow using length as the value of the name field in the ABI, but you cannot use
result['length']to read its value. - Bump
axiosfrom 1.8.3 to 1.11.0, bumpeslintfrom 9.22.0 to 9.31.0.
Bug Fixes
- Fix the issue where
addUpdateDatatreats numeric strings as numbers.#629- Starting from TronWeb v6.0.4,
addUpdateDatawill useTronWeb.fromUtf8to convert the provided data string—unless it starts with '0x'. - If the resulting data string has an odd length, a '0' will be prepended to ensure even length.
- Starting from TronWeb v6.0.4,